<template>
  <div class="JNPF-common-layout">
    <div class="JNPF-common-layout-center">
      <el-row class="JNPF-common-search-box" :gutter="16">
        <el-form @submit.native.prevent label-width="80px" label-position="left">
          <el-col :span="8">
            <el-form-item label="申请日期">
              <el-date-picker
                v-model="alarmdate"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"/>
              </el-form-item>
          </el-col>
          <el-col :span="8">
             <el-form-item label="单据编号"><el-input
              v-model="listQuery.fbillno"
              clearable
              class="filter-item"
              placeholder="请输入单据编号"
            /></el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="8">
            <el-form-item label="单据状态">
          <el-select
        v-model="listQuery.fbillstate"
        class="filter-item"
        clearable
        placeholder="请选择单据状态"
      >
        <el-option
          v-for="item in fbillstateOptions"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
        </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="存放地点">
              <el-select style="display: inline-block" clearable filterable v-model="listQuery.fpointNo" class="filter-item" placeholder="请选择存放地点">
                <el-option
                v-for="item in getListfpointNo"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class="searchOne" label="申请人员">
              <el-select style="display: inline-block" clearable filterable v-model="listQuery.fuseuser" class="filter-item" placeholder="请选择申请人员">
                <el-option
                v-for="item in getListfuseuser"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
            </el-form-item>
          </el-col>
          </template>
          <el-col :span="8">
            <el-form-item>
          <el-button type="primary" @click="handleFilter">查找</el-button>
          <el-button type="text" icon="el-icon-arrow-down" @click="showAll=true"
                v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll=false" v-else>
                收起</el-button>
          </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="JNPF-common-layout-main JNPF-flex-main">
       <!-- 查询结果 -->
    <JNPF-table  v-loading="listLoading" :data="list" >
     <el-table-column :width="buttonColor.operationOne" align="center" label="操作" class-name="small-padding">
        <template slot-scope="scope">
          <el-button type="text" @click="handleUpdate(scope.row)">浏览</el-button>
        </template>
      </el-table-column>
      <el-table-column :width="buttonColor.line" :index="indexMethod" align="center" label="序" type="index" />
      <el-table-column :width="buttonColor.billno" align="left" label="单据编号" prop="fbillno" />
      <el-table-column :formatter="formatfpointNo" align="left" label="存放地点" prop="fpointNo" />
      <el-table-column :width="buttonColor.user" :formatter="formatfuseuser" align="left" label="使用人员" prop="fuseuser" />
      <el-table-column :width="buttonColor.date" :formatter="datetimeFormat" align="left" label="申请日期" prop="fusedate" />
      <el-table-column :width="buttonColor.date" :formatter="datetimeFormat" align="left" label="使用日期" prop="fplanusedate" />
      <el-table-column :width="buttonColor.date" :formatter="timeFormat" align="left" label="开始时间" prop="frealbegtime" />
      <el-table-column :width="buttonColor.date" :formatter="timeFormat" align="left" label="结束时间" prop="frealendtime" />
      <el-table-column :width="buttonColor.num" align="center" label="人数" prop="fmancount" />
      <el-table-column :width="buttonColor.state" align="left" label="单据状态" prop="fbillstate" >
         <template slot-scope="scope">
          <span
            :style="{color:buttonColor.itemisconfirmed}"
            v-if="scope.row.fbillstate === 1"
            >{{ scope.row.fbillstate | statusFilter }}</span
          >
          <span :style="{color:buttonColor.itemconfirmed}" v-else-if="scope.row.fbillstate === 2">{{
            scope.row.fbillstate | statusFilter
          }}</span>
          <span :style="{color:buttonColor.statedisable}" v-else-if="scope.row.fbillstate === 3">{{
            scope.row.fbillstate | statusFilter
          }}</span>
          <span :style="{color:buttonColor.iteminvalid}" v-else>{{
            scope.row.fbillstate | statusFilter
          }}</span>
        </template>
      </el-table-column>
    </JNPF-table>
    <paginations
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      />
      </div>
    </div>
     <el-dialog :close-on-click-modal="false" title="浏览" :fullscreen="true" :before-close="handleClose" :visible.sync="dialogFormVisible">
      <el-tabs type="border-card">
        <el-tab-pane label="头表" :style="{height:screenHeight-230+'px'}">
          <el-row class="JNPF-common-search-box" :gutter="16">
            <el-form @submit.native.prevent label-width="80px" label-position="left">
              <el-col :span="6">
                <el-form-item class="required" label="单据编号" prop="fbillno">
          <el-input disabled v-model="dataForm.fbillno"/>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                 <el-form-item class="required" label="申请日期" prop="fusedate">
          <el-date-picker disabled v-model="dataForm.fusedate" type="date"/>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="单据状态" prop="fbillstate">
              <el-select
              disabled
            v-model="dataForm.fbillstate"
            class="filter-item"
            clearable
            placeholder="请选择单据状态"
          >
            <el-option
              v-for="item in fbillstateOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="申请人员" prop="fuseuser">
                <el-select disabled clearable filterable v-model="dataForm.fuseuser" class="filter-item" placeholder="请选择申请人员">
                <el-option
                v-for="item in getListfuseuser"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="存放地点" prop="fpointNo">
                 <el-select disabled @change="pointChange" clearable filterable v-model="dataForm.fpointNo" class="filter-item" placeholder="请选择存放地点">
                <el-option
                v-for="item in getListfpointNo"
              :key="item.value"
              :label="item.label"
              :value="item.value"/>
              </el-select>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="申请人数" prop="fmancount">
          <el-input disabled v-model.number="dataForm.fmancount"/>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="开始时间" prop="frealbegtime">
          <el-time-picker disabled v-model="dataForm.frealbegtime" placeholder="开始时间" />
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="结束时间" prop="frealendtime">
          <el-time-picker disabled v-model="dataForm.frealendtime" placeholder="结束时间" />
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="required" label="使用日期" prop="fplanusedate">
          <el-date-picker disabled v-model="dataForm.fplanusedate" type="date"/>
        </el-form-item>
              </el-col>
              <el-col :span="6">
                <el-form-item class="text" style="width:96%" label="摘要" prop="fexplanation">
          <el-input disabled v-model="dataForm.fexplanation"/>
        </el-form-item>
              </el-col>
            </el-form>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="明细表">
          <!-- 查询结果 -->
                  <JNPF-table :height="screenHeight-230" v-loading="listLoading" :data="dataForm.details">
                    <el-table-column width="60" align="center" label="行号" prop="fline" />
                    <el-table-column align="center" label="容器标签" prop="frfidbarcode" />
                    <el-table-column align="center" label="物料编号" prop="fgoodno" />
                    <el-table-column :formatter="formatfgoodno" align="left" label="物料名称" prop="fgoodname" />
                    <el-table-column align="center" label="剩余量" prop="fbalqty" />
                    <el-table-column align="center" label="申请量" prop="fretqty" />
                    <el-table-column align="center" label="使用量" prop="fuseqty" />
                    <el-table-column :formatter="datetimeFormat" align="left" label="生产日期" prop="fprocdate" />
                  </JNPF-table>
        </el-tab-pane>
      </el-tabs>
      <span slot="footer" class="dialog-footer">
        <el-button type="info"  @click="cancel()">取消</el-button>
      </span>
     </el-dialog>
  </div>
</template>
<script>
import { listuseHead, createuseHead, updateuseHead, deleteuseHead } from '@/api/useHead2'
import moment from 'moment'
import { tableColor,titleColor,buttonColor } from '@/filters/index'
import { getListArea, getFbillno } from '@/api/area'

const statusMap = {
  1: '预约中',
  2: '已批准',
  3: '不核准',
  8: '已取消'
}

export default {
  name: 'ITcUseHead2',
   filters: {
    statusFilter(type) {
      return statusMap[type]
    }
  },
  data() {
    return {
      panelHeight: 0,
      buttonColor,
      materialIdVisible: false,
      materialFsiteNo: null,
      labFlag:null,
      searchVisiblelab: false,
      labDialogFsiteNo: null,
      userFlag:null,
      searchVisibleuse: false,
      userDialogFsiteNo:null,
      goodAllList: [],
      dialogFormVisible1: false,
      detailsTmp: [],
      listTmp: [],
      dataForm1: {
        fbillno: undefined,
        fline: undefined,
        frfidbarcode: undefined,
        fgoodno: undefined,
        fgoodname: undefined,
        fbuyprice: undefined,
        fbalqty: undefined,
        fretqty: undefined,
        fuseqty: undefined,
        fboxbarcode: undefined,
        fcabbarcode: undefined,
        fmemo: undefined,
        fprocdate: undefined,
      },
      flineList:[],
      selectList:[],

      getListfuseuser: [],
      getListfpointNo: [],
      list: null,
      total: 0,
      listLoading: true,
      alarmdate: null,
      listQuery: {
        page: 1,
        limit: 20,
        fsiteNo: this.$store.state.user.fsiteNo,
        fuseuser: undefined,
        fusedate: undefined,
        fplanusedate: undefined,
        ftakedateStart: undefined,
        ftakedateEnd: undefined,
        fpointNo: undefined,
        fmancount: undefined,
        fplanbegtime: undefined,
        fplanendtime: undefined,
        frealbegtime: undefined,
        frealendtime: undefined,
        fexplanation: undefined,
        faudituser: undefined,
        fauditdate: undefined,
        fauditnote: undefined,
        fupddate: undefined,
        foperator: undefined,
        fcheckdate: undefined,
        fcheckuser: undefined,
        fbillstate: undefined,
        fbilltype: 0,
        sort: 'create_time',
        order: 'desc'
      },
      showAll:false,
      screenHeight: document.body.clientHeight,
      dataForm: {
        fsiteNo: undefined,
        fuseuser: undefined,
        fusedate: undefined,
        fplanusedate: undefined,
        fpointNo: undefined,
        fmancount: undefined,
        fplanbegtime: undefined,
        fplanendtime: undefined,
        frealbegtime: undefined,
        frealendtime: undefined,
        fexplanation: undefined,
        faudituser: undefined,
        fauditdate: undefined,
        fauditnote: undefined,
        fupddate: undefined,
        foperator: undefined,
        fcheckdate: undefined,
        fcheckuser: undefined,
        fbillstate: undefined,
        id: undefined,
        details: []
      },
      tableColor: tableColor,
      titleColor: titleColor,
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: '编辑',
        create: '创建'
      },
      rules: {
        fsiteNo: [
          { required: true, message: '客户编号不能为空' },
        ],
        fuseuser: [
          { required: true, message: '申请人员不能为空' },
        ],
        fusedate: [
          { required: true, message: '申请日期不能为空' },
        ],
        fplanusedate: [
          { required: true, message: '使用日期不能为空' }
          ],
        frealbegtime: [
          { required: true, message: '开始时间不能为空' }
          ],
        frealendtime: [
          { required: true, message: '结束时间不能为空' }
          ],
        fpointNo: [
          { required: true, message: '存放地点不能为空' },
        ],
        fmancount: [
           { required: true, message: '申请人数不能为空' },
          { type: 'number', message: '申请人数必须为数字值' },
        ],
        fbillstate: [
          { type: 'number', message: '单据状态必须为数字值' },
        ],
      },
      rules1: {
        fline: [
          { required: true, message: '行号不能为空' },
          { type: 'number', message: '行号必须为数字值' },
        ],
        frfidbarcode: [
          { required: true, message: '容器标签不能为空' },
        ],
        fgoodno: [
          { required: true, message: '物料编号不能为空' },
        ],
        fbuyprice: [
          { required: true, message: '采购价不能为空' },
        ],
        fbalqty: [
          { required: true, message: '剩余量不能为空' },
        ],
        fuseqty: [
          { required: true, message: '使用量不能为空' },
        ],
        fboxbarcode: [
          { required: true, message: '储物仓固定资产码不能为空' },
        ],
        fcabbarcode: [
          { required: true, message: '储物柜固定资产码不能为空' },
        ],
      },
      fbillstateOptions: [
        { value: 1, label: '预约中' },
        { value: 2, label: '已批准' },
        { value: 3, label: '不核准' },
        { value: 8, label: '已取消' },
      ]
    }
  },
  created() {
    this.panelHeight = document.documentElement.clientHeight-335
    this.alarmdate = [new Date(), new Date()]
    this.getList()
    // 地点
      getListArea({ flag: 10,arg1:this.$store.state.user.fsiteNo })
      .then(response => {
        this.getListfpointNo = response.data.data.list
      })
      .catch(() => {
        this.getListfpointNo = []
      })
      // 人员弹出框
      getListArea({flag:13,arg1:this.$store.state.user.fsiteNo})
      .then(response => {
        this.getListfuseuser = response.data.data.list
      })
      .catch(() => {
        this.getListfuseuser = []
      })
        // 物料
    getListArea({ flag: 31 })
      .then(response => {
        this.goodAllList = response.data.data.list
      })
      .catch(() => {
        this.goodAllList = []
      })
  },
  methods: {
    datetimeFormat(row, column) {
      const date = row[column.property]
      if (date === undefined || date === null) {
        return ''
      }
      return moment(date).format('YYYY-MM-DD')
    },
    timeFormat(row, column) {
      const date = row[column.property];
      if (date === undefined || date === null) {
        return "";
      }
      return moment(date).format("HH:mm:ss");
    },
    formatDate: function(date) {
      if(typeof(date)==='object'){
         var ym
      var y = date.getFullYear()
      var m = date.getMonth() + 1
      var d = date.getDate()
      if (m < 10) {
        m = '0' + m
      }
      if (d < 10) {
        d = '0' + d
      }
      ym = '' + y + m + d
      return ym
      }else{
        return date
      }
    },
    // 物料
    formatfgoodno: function(row, column) {
      if (this.goodAllList.length > 0) {
        for (let i = 0; i < this.goodAllList.length; i++) {
          if (row.fgoodno === this.goodAllList[i].value) {
            return this.goodAllList[i].label
          }
        }
        return ''
      } else {
        return ''
      }
    },

    // 物料弹出框
    searchDialogMaterial() {
      this.materialIdVisible = true
      this.materialFsiteNo = this.dataForm.fsiteNo
    },

    // 物料弹出框
    materialDialogValue(value){
        this.dataForm1.fgoodno = value.data.fgoodno
        this.dataForm1.fgoodname = value.data.fgoodname
        this.dataForm1.fbuyprice = value.data.fbuyprice
    },

     // 搜索地点弹出框
    searchDialoglab(value) {
      this.labFlag = value
      if(value === 'add'){
        this.labDialogFsiteNo = this.dataForm.fsiteNo
      }else{
        this.labDialogFsiteNo = this.listQuery.fsiteNo
      }
      this.searchVisiblelab = true
    },

    // 地点弹出框返回值
    labDialogValue(value){
      if(this.labFlag==='add'){
        this.dataForm.fpointNo = value.lab.fpointNo
        this.dataForm.details=[]
      }else{
        this.listQuery.fpointNo = value.lab.fpointNo
      }
    },

    // 地点改变
    pointChange(){
      this.dataForm.details=[]
    },
    // 地点
    formatfpointNo: function(row, column) {
      if (this.getListfpointNo) {
        for (let i = 0; i < this.getListfpointNo.length; i++) {
          if (row.fpointNo === this.getListfpointNo[i].value) {
            return this.getListfpointNo[i].label
          }
        }
        return ''
      } else {
        return ''
      }
    },

      // 搜索人员弹出框
    searchDialoguse(value) {
      this.userFlag = value
      if(value === 'add'){
        this.userDialogFsiteNo = this.dataForm.fsiteNo
      }else{
        this.userDialogFsiteNo = this.listQuery.fsiteNo
      }
      this.searchVisibleuse = true
    },

    // 人员弹出框返回值
    userDialogValue(value){
      if(this.userFlag==='add'){
        this.dataForm.fuseuser = value.user.id.toString()
      }else{
        this.listQuery.fuseuser = value.user.id.toString()
      }
    },

    // 人员
    formatfuseuser: function(row, column) {
      if(this.getListfuseuser){
        for (let i = 0; i < this.getListfuseuser.length; i++) {
        if (row.fuseuser == this.getListfuseuser[i].value) {
          return this.getListfuseuser[i].label
        }
      }
      return ''
      }else{
      return ''
      }
    },
    getList() {
      this.listQuery.ftakedateStart = this.alarmdate == null ? null : this.formatDate(this.alarmdate[0])
      this.listQuery.ftakedateEnd = this.alarmdate == null ? null : this.formatDate(this.alarmdate[1])
      this.listLoading = true
      listuseHead(this.listQuery)
        .then(response => {
          this.list = response.data.data.list
          this.total = response.data.data.total
          this.listLoading = false
        })
        .catch(() => {
          this.list = []
          this.total = 0
          this.listLoading = false
        })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    resetForm() {
      this.dataForm = {
        fsiteNo: undefined,
        fuseuser: undefined,
        fusedate: undefined,
        fplanusedate: undefined,
        fpointNo: undefined,
        fmancount: undefined,
        fplanbegtime: undefined,
        fplanendtime: undefined,
        frealbegtime: undefined,
        frealendtime: undefined,
        fexplanation: undefined,
        faudituser: undefined,
        fauditdate: undefined,
        fauditnote: undefined,
        fupddate: undefined,
        foperator: undefined,
        fcheckdate: undefined,
        fcheckuser: undefined,
        fbillstate: undefined,
        id: undefined,
        details: []
      }
    },
    handleCreate() {
      this.resetForm()
      // 单据编号
      getFbillno({ flag: 2026 })
        .then((response) => {
          if (response) {
            this.dataForm.fbillno = response.data.data
            this.dialogFormVisible = true
            this.$nextTick(() => {
            this.$refs['dataForm'].clearValidate()
          })
          }
        })
        .catch(() => {
          this.dataForm.fbillno = ''
        })
        this.dataForm.fbillstate = 1
        this.dataForm.fusedate = new Date()
        this.dataForm.fsiteNo = this.$store.state.user.fsiteNo;
        this.dataForm.fuseuser = this.$store.state.user.id.toString()
        const day3 = new Date();
        // 使用日期默认D+1
        day3.setTime(day3.getTime()+24*60*60*1000);
        const tem = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();
        this.dataForm.fplanusedate=this.parserDate(tem)
      this.dialogStatus = 'create'
    },
    parserDate(date) {
      var t = Date.parse(date)
      if (!isNaN(t)) {
        return new Date(Date.parse(date.replace(/-/g, '/')))
      }
    },
    year(date){
      var ym
      var y = date.getFullYear()
      var m = date.getMonth() + 1
      var d = date.getDate()
      if (m < 10) {
        m = '0' + m
      }
      if (d < 10) {
        d = '0' + d
      }
      ym = '' + y + '-' + m + '-'  + d
      return ym
    },
    hour(date){
      var ym
      var h = date.getHours()
      var ms = date.getMinutes()
      var s = date.getSeconds()
      ym = '' + h + ':'  + ms + ':' + s
      return ym
    },
    createData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          this.dataForm.frealbegtime = this.parserDate(this.year(this.dataForm.fplanusedate)+' '+this.hour(this.dataForm.frealbegtime))
           this.dataForm.frealendtime = this.parserDate(this.year(this.dataForm.fplanusedate)+' '+this.hour(this.dataForm.frealendtime))
          createuseHead(this.dataForm)
            .then(response => {
              this.list.unshift(response.data.data)
              this.dialogFormVisible = false
              this.$notify.success({
                title: '成功',
                message: '添加物料申请主表成功'
              })
              this.selectList=[]
              this.flineList=[]
            })
            .catch(response => {
              this.$notify.error({
                title: '失败',
                message: response.data.data
              })
            })
        }
      })
    },
    handleUpdate(row) {
      this.dataForm = Object.assign({}, row)
      this.dialogStatus = 'update'
      this.dialogFormVisible = true
      this.detailsTmp = [];
      this.listTmp = row;
      row.details.forEach((v) => {
        this.detailsTmp.push(v);
        this.selectList.push(v.fgoodno)
        this.flineList.push(v.fline)
      });
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    yearup(date) {
      if (date === undefined || date === null) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD");
    },
    hourup(date) {
      if (date === undefined || date === null) {
        return "";
      }
      return moment(date).format("HH:mm:ss");
    },
    updateData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          this.dataForm.frealbegtime = this.parserDate(this.yearup(this.dataForm.fplanusedate)+' '+this.hourup(this.dataForm.frealbegtime))
           this.dataForm.frealendtime = this.parserDate(this.yearup(this.dataForm.fplanusedate)+' '+this.hourup(this.dataForm.frealendtime))
          updateuseHead(this.dataForm, this.$route.query.id)
            .then(() => {
              for (const v of this.list) {
                if (v.fbillno === this.dataForm.fbillno) {
                  const index = this.list.indexOf(v)
                  this.list.splice(index, 1, this.dataForm)
                  break
                }
              }
              this.dialogFormVisible = false
              this.$notify.success({
                title: '成功',
                message: '更新物料申请主表成功'
              })
              this.selectList=[]
              this.flineList=[]
            })
            .catch(response => {
              this.$notify.error({
                title: '失败',
                message: response.data.data
              })
            })
        }
      })
    },
    handleDelete(row) {
      this.$confirm('是否要删除物料申请主表', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteuseHead(row)
          .then(response => {
            this.$notify.success({
              title: '成功',
              message: '删除物料申请主表成功'
            })
            const index = this.list.indexOf(row)
            this.list.splice(index, 1)
          })
          .catch(response => {
            this.$notify.error({
              title: '失败',
              message: response.data.data
            })
          })
      })
    },
    addData() {
      this.$refs['dataForm1'].validate((valid) => {
          if (valid) {
          this.dialogFormVisible1 = false
          for (const v of this.dataForm.details) {
                if (v.fgoodno === this.dataForm1.fgoodno) {
                  const index = this.dataForm.details.indexOf(v)
                  this.dataForm.details.splice(index, 1, this.dataForm1)
                  break
                }
              }
          }
      })

    },

    cancel() {
      this.dialogFormVisible = false
      this.selectList=[]
      this.flineList=[]
      this.list.forEach((v) => {
        if (v.fbillno === this.dataForm.fbillno) {
          this.dataForm = this.listTmp
          this.dataForm.details = this.detailsTmp
          const index = this.list.indexOf(v)
          this.list.splice(index, 1, this.dataForm)
          return
        }
      })
    },

    // 弹窗点击关闭前的回调
      handleClose(){
        this.dialogFormVisible = false
        this.selectList=[]
      this.flineList=[]
        this.list.forEach((v) => {
          if (v.fbillno === this.dataForm.fbillno) {
            this.dataForm = this.listTmp
            this.dataForm.details = this.detailsTmp
            const index = this.list.indexOf(v)
            this.list.splice(index, 1, this.dataForm)
            return
          }
        })
      },

      handleUpdate1(row) {
      this.dataForm1 = Object.assign({}, row)
      this.dialogFormVisible1 = true
      this.dataForm1.fgoodname = this.formatfgoodno(row)
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },

     handleDelete1(row) {
      const index = this.dataForm.details.indexOf(row);
      this.dataForm.details.splice(index, 1);
      this.selectList.splice(index,1)
      this.flineList.splice(index,1)
    },
    indexMethod(index) {
      index = index + 1
      return index
    }
  }
}
</script>